package algorithm;

/**
 * 冒泡排序
 */
public class BubbleSort {
    public static void main(String[] args) {
        CreatArr creatArr = new CreatArr();
        int[] arr = creatArr.creatArr(10);

        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length-i-1 ; j++) {
                if (arr[j]>arr[j+1]){
                    int item = arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1] =item;
                }
            }
        }
        for (int j = 0; j < arr.length; j++) {
            System.out.print(arr[j]+" ");
        }
        System.out.println();
    }
}
